<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="com.hwhp.entity.*"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html>
	<head>
		<title>菜单</title>
		<LINK href="<%=basePath%>css/milkwhite.css" type=TEXT/CSS
			rel=StyleSheet></LINK>
		<LINK href="<%=basePath%>css/htmilkwhite.css" type=TEXT/CSS
			rel=StyleSheet></LINK>
		<LINK href="<%=basePath%>js/tree/dtree/dtree.css" type=text/css
			rel=StyleSheet>
		<SCRIPT src="<%=basePath%>js/tree/dtree/dtree.js" type=text/javascript></SCRIPT>
		<script type="text/javascript">
		 function addProcess(){
		  var menuid=document.getElementById("menuid").value;
		  var processtype=document.getElementById("processType").value;
		  if(menuid!=''){
		    if(processtype!='add'){
		      var name=document.getElementById("menuname").value;
		          document.getElementById("menuname").value="";
		      var code=document.getElementById("code").value;
		          document.getElementById("code").value="";
		     document.getElementById("parentid").value=menuid;
		     document.getElementById("parentname").value=name;
		     document.getElementById("parentcode").value=code;
		     document.getElementById("showparentcode").innerHTML=code;
		     document.getElementById("processview").innerHTML="新增";
		     document.getElementById("processType").value="add";
		      document.getElementById("buttonprcess").style.display="";
		      }
		  }else{
		    alert("请选择一个功能菜单后再进行新增操作！");
		  }
		 
		 }
		 function deleteProcess(){
		    var menuid=document.getElementById("menuid").value;
		  if(menuid!=''){
		     if(confirm("确定删除选择的功能吗？")){
		      document.getElementById("processType").value="delete";
		      fm1.submit();
		     }
		  }else{
		    alert("请选择一个功能菜单后再进行删除操作！");
		  }
		 
		 }
		  function updateProcess(){
		    var menuid=document.getElementById("menuid").value;
		  if(menuid!=''){
		     document.getElementById("processType").value="update";
		     document.getElementById("buttonprcess").style.display="";
		  }else{
		    alert("请选择一个功能菜单后再进行修改操作！");
		  }
		 
		 }
		  function init(){
		      var processtype=document.getElementById("processType").value;
		      //alert(processtype);
		      if(processtype!=""&&processtype!="null"){
		      //alert(parent.document.getElementById("workspace1").src);
		       parent.workspace1.location=parent.document.getElementById("workspace1").src;	
		      }
		  }
		</script>
	</head>
	<%
	    Deptment deptment=new Deptment();
	    Deptment parentDeptment=new Deptment();
	    String act=(String)request.getAttribute("act");
	    String actName="";
	    if("add".equals(act)){
	       actName="新增";
	    }
	    if("edit".equals(act)){
	       actName="编辑";
	    }
		 deptment = (Deptment) request.getAttribute("deptObj");
		 parentDeptment=(Deptment)request.getAttribute("parentObj");
		if (deptment == null) {
			deptment = new Deptment();
		}
		 if(parentDeptment==null){
		   parentDeptment=new Deptment();
		 }
	%>
	<body style="MARGIN: 0px;" onload="init()" id="body">
		<form name="fm1" action="/chis/manager/depart!insertDepart.action" method="post">
			<TABLE cellSpacing=10 width="100%">
				<TBODY>
					<tr>
						<td class=contenttab1 height="26px">
							当前操作：<%=deptment.getDeptName() == "" || deptment.getDeptName() == null ? "": deptment.getDeptName() + ">>"%>
							<span id="processview" style="color:red"><%=actName %></span>
						</td>
					</tr>
					<TR>
						<TD class=contenttab1 vAlign=top>
							<TABLE cellSpacing=2 cellPadding=0 width="100%" border=0>
								<TBODY>
									<TR>
										<TD class=contenttab2>
											部门名称
										</TD>
										<TD class=contenttab1 width="40%">
											<INPUT class=input3 id=departname name=departname
												value="<%=deptment.getDeptName()%>">
											<INPUT class=input3 id=departid name=departid
												value="<%=deptment.getDeptId()%>" type="hidden">
											<INPUT class=input3 id=act name=act
												value="<%=act%>" type="hidden">
										</TD>
										<TD class=contenttab2>
											上级部门
										</TD>
										<TD class=contenttab1 width="40%">
											<INPUT class=input3 id=parentname name=parentname
												value="<%=parentDeptment.getDeptName() %>" readonly="readonly">
											<INPUT class=input3 id=parentid name=parentid
												value="<%=parentDeptment.getDeptId() %>" type="hidden">
										</TD>
									</TR>
									<TR>
										<TD class=contenttab2>
											部门编码
										</TD>
										<TD class=contenttab1 width="40%">
											<INPUT class=input3 id=parentcode name=parentcode value=""
												type="hidden">
											<span id="showparentcode"></span>
											<INPUT class=input2 id=departcode name=departcode
												value="<%=deptment.getDeptCode()%>">
										</TD>
										<TD class=contenttab2>
											是否启用
										</TD>
										<TD class=contenttab1 width="40%">
											<input type="radio" name=isused " id="isused"
												checked="checked" value="1">
											启用
											<input type="radio" name="isused" id="isused" value="0">
											停用
										</TD>
									</TR>
									<TR>
										<TD class=contenttab2>
											备 注
										</TD>
										<TD class=contenttab1 colspan="3">
											<textarea class=input3 rows="8" cols="35" style="width: 100%" name="remark" id="remark"></textarea>
										</TD>
									</TR>
								</TBODY>
							</TABLE>
						</TD>
					</TR>
					<tr height="40">
						<td align="center">
							<table border='0' cellpadding='2' cellspacing='0' id="buttonprcess">
								<tr height="20">
									<td style='background-image:url(<%=basePath%>images/button/w_buttonrleft1.gif);width:6px;'></td>
									<td style='background-image:url(<%=basePath%>images/button/w_buttonmiddle1.gif);cursor: hand;' onclick="checkOption()">
										保存
									</td>
									<td style='background-image:url(<%=basePath%>images/button/w_buttonright1.gif);width:6px;'></td>
									<td>
										&nbsp;
									</td>
									<td style='background-image:url(<%=basePath%>images/button/w_buttonrleft1.gif);width:6px;'></td>
									<td style='background-image:url(<%=basePath%>images/button/w_buttonmiddle1.gif);cursor: hand;'>
										<a href="<%=basePath%>/html/manager/deptment/departManagerList.jsp">取消</a>
									</td>
									<td style='background-image:url(<%=basePath%>images/button/w_buttonright1.gif);width:6px;'></td>
									<td>
										&nbsp;
									</td>
									<td style='background-image:url(<%=basePath%>images/button/w_buttonrleft1.gif);width:6px;'></td>
									<td style='background-image:url(<%=basePath%>images/button/w_buttonmiddle1.gif);cursor: hand;'>
										<a href="/chis/manager/depart!departList.action?parentid=<%=parentDeptment.getDeptId()%>">返回</a>
									</td>
									<td style='background-image:url(<%=basePath%>images/button/w_buttonright1.gif);width:6px;'></td>
								</tr>
							</table>
						</td>
					</tr>
				</TBODY>
			</TABLE>
		</form>
	</body>
	<script type="text/javascript">
			function checkOption(){
				var deptId = document.getElementById("departid");
				//alert(deptId.value.length);
				if(deptId.value != null && deptId.value.length != 0){//如果是修改操作
					fm1.action="/chis/manager/depart!insertDepart.action?act=edit";
					fm1.submit();
					//alert('in the edit');
				}else{//如果是增加操作
					//alert('in the add');	
					fm1.action="/chis/manager/depart!insertDepart.action?act=add";
					fm1.submit();
				}
		
			}
	
	</script>
</html>
